package de.tmahr.android;

import de.tmahr.android.logger.LogActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class SingleTouchTest extends LogActivity implements OnTouchListener
{
	public SingleTouchTest()
	{
		super(SingleTouchTest.class.getSimpleName());
	}

	public void onCreate(Bundle b)
	{
		super.onCreate(b);
		textView.setOnTouchListener(this);
	}
	
	@Override
	public boolean onTouch(View v, MotionEvent event)
	{
		clearLog();
		StringBuilder stringBuilder = new StringBuilder();
		switch(event.getAction())
		{
		case MotionEvent.ACTION_DOWN:
			stringBuilder.append("down, ");
			break;
		case MotionEvent.ACTION_UP:
			stringBuilder.append("up, ");
			break;
		case MotionEvent.ACTION_MOVE:
			stringBuilder.append("move, ");
			break;
		case MotionEvent.ACTION_CANCEL:
			stringBuilder.append("cancel, ");
			break;			
		}
		stringBuilder.append(event.getX()).append(", ").append(event.getY()).append("\n");
		String s = stringBuilder.toString();
		log(s);
		return true;
	}
}
